package com.zhuanzhuan.hero.user.facade.label;

import cn.hutool.core.util.ObjectUtil;
import com.bj58.spat.scf.server.contract.annotation.ServiceBehavior;
import com.bj58.youpin.common.rpc.result.Result;
import com.bj58.zhuanzhuan.zzentry.common.service.entity.ServiceHeaderEntity;
import com.zhuanzhuan.hero.user.consts.NumConsts;
import com.zhuanzhuan.hero.user.dto.label.QueryBrandModelLabelDTO;
import com.zhuanzhuan.hero.user.entity.HeroLabelInfo;
import com.zhuanzhuan.hero.user.service.HeroLabelInfoService;
import com.zhuanzhuan.hero.user.service.IApolloService;
import com.zhuanzhuan.hero.user.service.impl.HeroLabelHandleService;
import com.zhuanzhuan.hero.user.vo.label.HeroContentFilterItemVO;
import com.zhuanzhuan.hero.user.vo.label.HeroPersonFilterItemVO;
import com.zhuanzhuan.hero.user.vo.label.LevelLabelVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.util.List;

/**
 * 筛选
 */
@ServiceBehavior
@Slf4j
public class UserLabelFacade implements IUserFilterLabelFacade {

    @Autowired
    private HeroLabelInfoService heroLabelInfoService;

    @Autowired
    private HeroLabelHandleService heroLabelHandleService;
    @Resource
    private HeroLabelInfoService labelInfoService;


    @Override
    public Result<HeroPersonFilterItemVO> getPersonFilterItem(Integer tabType) {
        //todo 添加缓存;  做一个手动清除缓存的接口;
        List<HeroLabelInfo> heroLabelInfos = heroLabelInfoService.queryAllLabelType2();
        if(ObjectUtil.isEmpty(heroLabelInfos)){
            return Result.fail(NumConsts.SYSTEM_CODE.intValue(), "请先配置标签");
        }

        HeroPersonFilterItemVO vo=new HeroPersonFilterItemVO();
        vo.setAdvantageCateList(heroLabelHandleService.getAdvantageCateList());
        vo.setFinenessList(heroLabelHandleService.getFinenessList(heroLabelInfos));
        vo.setChannelPreferenceList(heroLabelHandleService.getChannelPreferenceList(heroLabelInfos));
        vo.setMainCateList(heroLabelHandleService.getMainCateList(heroLabelInfos));
        vo.setServiceList(heroLabelHandleService.getServiceList(heroLabelInfos));

        return Result.success(vo);
    }

    @Override
    public Result<List<LevelLabelVO>> getContentFilterItem(Integer tabType) {
        QueryBrandModelLabelDTO queryBrandModelLabelDTO=new QueryBrandModelLabelDTO();
        List<LevelLabelVO> levelLabelVOS = labelInfoService.queryContentCategoryLabels(queryBrandModelLabelDTO);
        return Result.success(levelLabelVOS);
    }


}
